﻿using Api.Dal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Api.Bll
{
    public class BllFactory
    {
        public static UserBLL? ub;
        public static AdminBll? ab;
        public static CommentBll? cb;
        public static PostBLL? pb;
         public static MessageBll? mb;
        public static UserBLL GetUserBLL() { 
            if(ub == null) { 
                ub = new UserBLL(); 
                ub.count = UserDal.GetCount();
            }
            return ub!; 
        }
        public static AdminBll GetAdminBLL()
        {
            if (ab == null) { 
                ab = new AdminBll();
                ab.count = AdminDAL.GetCount();
            }
            return ab!;
        }
        public static CommentBll GetCommentBLL()
        {
            if (cb == null) { 
                cb = new CommentBll();
                cb.count = CommentDAL.GetCount();
            }
            return cb!;
        }
        public static PostBLL GetPostBLL()
        {
            if (pb == null) { 
                pb = new PostBLL();
                pb.count = PostDAL.GetCount();
            }
            return pb!;
        }
        
         public static MessageBll GetMessageBLL() // 添加 MessageBLL 的获取方法
        {
            if (mb == null) 
            { 
                mb = new MessageBll();
                mb.count = 0; // 或者设置为合适的初始值
            }
            return mb!;
        }
    }
}
